package com.xiaoxu.privatechat.dao.common;


import com.xiaoxu.privatechat.entity.common.AccountGroup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @description 聊天会话数据库操作层
 * @author xiaoxu
 * @date 2023/2/13
 */
@Repository
public interface AccountGroupDao extends JpaRepository<AccountGroup, Long> {

	/**
	 * @description 根据群id查询群信息
	 * @param id 群id
	 * @return AccountGroup
	 */
	@Query("select ag from AccountGroup ag where ag.id = :id")
	AccountGroup find(@Param("id")Long id);

	/**
	 * @description 通过群主id查找群
	 * @param id 群主id
	 * @return List<AccountGroup>
	 */
	List<AccountGroup> findByAdminId(Long id);
}
